﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataObject.DataAccess;

namespace TreasureJunk.Utility
{
    public class SessionUtils
    {
        public static decimal BreakfastPrice
        {
            get
            {
                if (null == HttpContext.Current.Session["Breakfast"])
                {
                    GetConfiguration();
                }
                return Convert.ToDecimal(HttpContext.Current.Session["Breakfast"]);
            }
        }

        public static decimal LunchPrice
        {
            get
            {
                if (null == HttpContext.Current.Session["Lunch"])
                {
                    GetConfiguration();
                }
                return Convert.ToDecimal(HttpContext.Current.Session["Lunch"]);
            }
        }

        public static decimal DinnerPrice
        {
            get
            {
                if (null == HttpContext.Current.Session["Dinner"])
                {
                    GetConfiguration();
                }
                return Convert.ToDecimal(HttpContext.Current.Session["Dinner"]);
            }
        }

        public static decimal Usd
        {
            get
            {
                if (null == HttpContext.Current.Session["Usd"])
                {
                    GetConfiguration();
                }
                return Convert.ToDecimal(HttpContext.Current.Session["Usd"]);
            }
        }

        public static decimal Eur
        {
            get
            {
                if (null == HttpContext.Current.Session["Eur"])
                {
                    GetConfiguration();
                }
                return Convert.ToDecimal(HttpContext.Current.Session["Eur"]);
            }
        }

        private static void GetConfiguration()
        {
            var config = ConfigurationDAO.CreateInstant().Get();
            HttpContext.Current.Session["Breakfast"] = config.Breakfast;
            HttpContext.Current.Session["Lunch"] = config.Lunch;
            HttpContext.Current.Session["Dinner"] = config.Dinner;
            HttpContext.Current.Session["Usd"] = config.Usd;
            HttpContext.Current.Session["Eur"] = config.Eur;
        }
    }
}